package edu.seu.mart.entity;

import javax.servlet.http.HttpServletRequest;

/**
 * 在service层获取应用层中的核心数据
 */
public class SystemRequest {
    /**
     * 分页大小
     */
    private int pageSize;
    /**
     * 分页起始页
     */
    private int pageOffset;
    /**
     * 列表的排序字段
     */
    private String sort;
    /**
     * 列表的排序方式（升序或降序）
     */
    private String order;
    /**
     * 获得站点根目录在文件系统上的位置
     */
    private HttpServletRequest request;
    private String realpath;

    public String getRealpath() {
        if (request != null) {
            realpath = request.getSession().getServletContext().getRealPath("");
        }
        return realpath;
    }


    public void setRealpath(String realpath) {
        this.realpath = realpath;
    }

    public int getPageSize() {
        return (pageSize <= 0) ? 15 : pageSize;
    }

    public int getPageOffset() {
        return (pageOffset <= 0) ? 0 : pageOffset;
    }

    public String getSort() {
        return sort;
    }

    public String getOrder() {
        return order;
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setPageOffset(int pageOffset) {
        this.pageOffset = pageOffset;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }
}
